import { useNavigate } from "react-router";
import st from "./header.module.css";

import BACK from "@/assets/img/返回.svg";
const Header = ({
  children,
  isHome = false,
  leftIcon = false,
  rightIcon = false,
  marginLeft = "",
  haveSelect = false,
  singleText = false,
}: any) => {
  const navigate = useNavigate();

  return (
    <div className={`${isHome ? st.homeHeader : st.otherHeader}`}>
      {leftIcon && (
        <img src={BACK} className={st.leftIcon} onClick={() => navigate(-1)} />
      )}
      <span
        className={isHome ? st.text : st.otherText}
        style={{ marginLeft: singleText?'39vw':marginLeft }}
      >
        {children}
      </span>
      {rightIcon && (
        <span
          className={`${st.rightIcon} ${haveSelect ? st.active : ""}`}
          onClick={() => navigate("/filter")}
        >
          筛选
        </span>
      )}
      {haveSelect && <div className={st.alert}></div>}
    </div>
  );
};
export default Header;
